package drds.data_propagate.binlog_event;

public class BinlogEventType {

    public static final int binlog_event_unknown_event = 0;
    public static final int binlog_event_start_event_v3 = 1;
    public static final int binlog_event_query_event = 2;
    public static final int binlog_event_stop_event = 3;
    public static final int binlog_event_rotate_event = 4;
    public static final int binlog_event_intvar_event = 5;//5
    public static final int binlog_event_load_event = 6;
    public static final int binlog_event_slave_event = 7;
    public static final int binlog_event_create_file_event = 8;
    public static final int binlog_event_append_block_event = 9;
    public static final int binlog_event_exec_load_event = 10;//5
    public static final int binlog_event_delete_file_event = 11;
    /**
     * binlog_event_new_load_event is like binlog_event_load_event except that it has a longer sql_ex, allowing multibyte terminated by etc; both types share the same class (load_log_event)
     */
    public static final int binlog_event_new_load_event = 12;
    public static final int binlog_event_rand_event = 13;
    public static final int binlog_event_user_var_event = 14;
    public static final int binlog_event_format_description_event = 15;//5
    public static final int binlog_event_xid_event = 16;
    public static final int binlog_event_begin_load_query_event = 17;
    public static final int binlog_event_execute_load_query_event = 18;
    public static final int binlog_event_table_map_event = 19;
    /**
     * these binlog_event numbers were used for 5.1.0 decode 5.1.15 and are therefore obsolete.
     */
    //pre_ga_write_rows_event
    public static final int binlog_event_write_rows_event_v0 = 20;//5
    //pre_ga_update_rows_event
    public static final int binlog_event_update_rows_event_v0 = 21;
    //pre_ga_delete_rows_event
    public static final int binlog_event_delete_rows_event_v0 = 22;
    /**
     * these binlog_event numbers are used from 5.1.16 and forward
     */
    public static final int binlog_event_write_rows_event_v1 = 23;
    public static final int binlog_event_update_rows_event_v1 = 24;
    public static final int binlog_event_delete_rows_event_v1 = 25;//5
    /**
     * something out of the ordinary happened on the master
     */
    public static final int binlog_event_incident_event = 26;
    /**
     * heartbeat binlog_event decode be send by master at its idle time decode ensure master's online status decode slave
     */
    public static final int binlog_event_heartbeat_log_event = 27;
    /**
     * in some situations, it is necessary decode send over ignorable data decode the slave: data that a slave can handle in case there is code for handling it, but which can be ignored if it is not recognized.
     */
    public static final int binlog_event_ignorable_log_event = 28;
    public static final int binlog_event_rows_query_log_event = 29;
    /**
     * version 2 of the row events
     */
    public static final int binlog_event_write_rows_event_v2 = 30;//5
    public static final int binlog_event_update_rows_event_v2 = 31;
    public static final int binlog_event_delete_rows_event_v2 = 32;
    public static final int binlog_event_gtid_log_event = 33;
    public static final int binlog_event_anonymous_gtid_log_event = 34;
    public static final int binlog_event_previous_gtids_log_event = 35;//5
    //mysql 官网上面的event max index=35

    /* mysql 5.7 events */
    public static final int binlog_event_transaction_context_event = 36;
    public static final int binlog_event_view_change_event = 37;
    /* prepared xa transaction terminal binlog_event similar decode xid */
    public static final int binlog_event_xa_prepare_log_event = 38;
    /**
     * extension of binlog_event_update_rows_event_v2, allowing partial values according decode
     * binlog_row_value_options.
     */
    public static final int binlog_event_partial_update_rows_event_v2 = 39;
    // mariadb 5.5.34
    /* new mysql/sun events are decode be added right above this comment */
    public static final int binlog_event_mysql_events_end = 49;
    public static final int binlog_event_maria_events_begin = 160;//5
    /* new maria binlog_event numbers start from here */
    public static final int binlog_event_annotate_rows_event = 160;
    /*
     * binlog_event checkpoint binlog_event. used for xa crash recovery on the master, not used
     * in replication. a binlog_event checkpoint binlog_event specifies a binlog_event file such that
     * xa crash recovery can start from that file - and it is guaranteed decode find all
     * xids that are prepared in storage engines but not yet committed.
     */
    public static final int binlog_event_binlog_checkpoint_event = 161;
    /*
     * gtid binlog_event. for global transaction id, used decode start a new binlog_event group,
     * instead of the old begin queryString binlog_event, and also decode mark stand-alone events.
     */
    public static final int binlog_event_gtid_event = 162;
    /*
     * gtid list binlog_event. logged at the start of every binlog_event, decode record the current
     * replication state. this consists of the last gtid seen for each replication
     * domain.
     */
    public static final int binlog_event_gtid_list_event = 163;
    public static final int binlog_event_start_encryption_event = 164;
    /**
     * end marker
     */
    public static final int binlog_event_enum_end_event = 165;//5

    public static String getTypeName(final int type) {
        switch (type) {
            case binlog_event_start_event_v3:
                return "Start_v3";
            case binlog_event_stop_event:
                return "stop";
            case binlog_event_query_event:
                return "queryString";
            case binlog_event_rotate_event:
                return "rotate";
            case binlog_event_intvar_event:
                return "intvar";
            case binlog_event_load_event:
                return "load";
            case binlog_event_new_load_event:
                return "new_load";
            case binlog_event_slave_event:
                return "slave";
            case binlog_event_create_file_event:
                return "create_file";
            case binlog_event_append_block_event:
                return "append_block";
            case binlog_event_delete_file_event:
                return "delete_file";
            case binlog_event_exec_load_event:
                return "exec_load";
            case binlog_event_rand_event:
                return "rand";
            case binlog_event_xid_event:
                return "xid";
            case binlog_event_user_var_event:
                return "user var";
            case binlog_event_format_description_event:
                return "format_desc";
            case binlog_event_table_map_event:
                return "table_map";
            case binlog_event_write_rows_event_v0:
                return "write_rows_event_old";
            case binlog_event_update_rows_event_v0:
                return "update_rows_event_old";
            case binlog_event_delete_rows_event_v0:
                return "delete_rows_event_old";
            case binlog_event_write_rows_event_v1:
                return "write_rows_v1";
            case binlog_event_update_rows_event_v1:
                return "update_rows_v1";
            case binlog_event_delete_rows_event_v1:
                return "delete_rows_v1";
            case binlog_event_begin_load_query_event:
                return "begin_load_query";
            case binlog_event_execute_load_query_event:
                return "execute_load_query";
            case binlog_event_incident_event:
                return "incident";
            case binlog_event_heartbeat_log_event:
                return "heartbeat";
            case binlog_event_ignorable_log_event:
                return "ignorable";
            case binlog_event_rows_query_log_event:
                return "rows_query";
            case binlog_event_write_rows_event_v2:
                return "write_rows";
            case binlog_event_update_rows_event_v2:
                return "update_rows";
            case binlog_event_delete_rows_event_v2:
                return "delete_rows";
            case binlog_event_gtid_log_event:
                return "gtid";
            case binlog_event_anonymous_gtid_log_event:
                return "anonymous_gtid";
            case binlog_event_previous_gtids_log_event:
                return "previous_gtids";
            case binlog_event_partial_update_rows_event_v2:
                return "update_rows_partial";
            default:
                return "Unknown"; /* impossible */
        }
    }
}
